﻿Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Frm_INTElementmanagement

    Implements IDServer.IDServer.IDServer



#Region "Definetation"

    Private Returenelement As New DataSet
    Private Returenelementout As New DataSet

#End Region

#Region "System Variabled Define"

    Public ActionHelp As IDServer.IDServer.ActionBtn = IDServer.IDServer.ActionBtn.ActionHelp

    Private WithEvents MainForm As Frm_MainForm

    Public Property SelectObject() As Frm_MainForm
        Get
            Return MainForm
        End Get
        Set(ByVal value As Frm_MainForm)
            MainForm = value
        End Set
    End Property

#End Region

#Region "BindingDgv"

    Private Sub loadDgvelement()
        Try
            Dim Elementtable As New DataTable
            With Elementtable.Columns
                .Add("BoNumA")
                .Add("GoodsBarcode")
                .Add("element")
                .Add("elementamount")
                .Add("elementunit")
                .Add("elementbatch")
                .Add("storeplace")
                .Add("elementstatus")
                .Add("builtdate")
                .Add("builtcomputer")
            End With
            Dim Elementrst As New DataSet
            Elementrst.Tables.Add(Elementtable)
            Me.Dgvelement.DataSource = Elementrst.Tables(0).DefaultView

            With Me.Dgvelement
                For i As Integer = 0 To .Columns.Count - 1
                    Dim Ikey As String = .Columns(i).Name
                    Dim Captionstr As String = Bindhasttable(0).Item(Ikey)
                    .Columns(i).HeaderText = Captionstr
                Next

                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
                .ScrollBars = ScrollBars.Both
                .SelectionMode = DataGridViewSelectionMode.FullRowSelect
                .AutoGenerateColumns = True
                .ReadOnly = False
            End With

        Catch ex As Exception

        End Try

    End Sub

    Private Sub loadDgvelementout()
        Try
            Dim Elementtable As New DataTable
            With Elementtable.Columns
                .Add("BoNumB")
                .Add("GoodsBarcode")
                .Add("element")
                .Add("elementamount")
                .Add("elementunit")
                .Add("elementbatch")
                .Add("elementplace")
                .Add("elementstatus")
                .Add("builtdate")
                .Add("builtcomputer")
            End With
            Dim Elementrst As New DataSet
            Elementrst.Tables.Add(Elementtable)
            Me.Dgvelementout.DataSource = Elementrst.Tables(0).DefaultView

            With Me.Dgvelementout
                For i As Integer = 0 To .Columns.Count - 1
                    Dim Ikey As String = .Columns(i).Name
                    Dim Captionstr As String = Bindhasttable(1).Item(Ikey)
                    .Columns(i).HeaderText = Captionstr
                Next

                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

                .SelectionMode = DataGridViewSelectionMode.FullRowSelect
                .ReadOnly = True

            End With

        Catch ex As Exception

        End Try

    End Sub

    Private Sub loadDgvelementC()
        Try
            Dim ElementC As New DataTable
            With ElementC.Columns
                .Add("goodsbarcode")
                .Add("element")
                .Add("Enname")
                .Add("Cnname")
                .Add("elementamount")
                .Add("elementunit")
                .Add("elementbatch")
                .Add("elementstatus")
                .Add("storeplace")
            End With

            Dim ElementcRST As New DataSet
            ElementcRST.Tables.Add(ElementC)
            Me.DgvelementC.DataSource = ElementcRST.Tables(0)

            With Me.DgvelementC
                For i As Integer = 0 To .Columns.Count - 1
                    Dim mKey As String = .Columns(i).Name
                    Dim capationStr As String = Bindhasttable(2).Item(mKey)
                    .Columns(i).HeaderText = capationStr
                Next

                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

                .SelectionMode = DataGridViewSelectionMode.FullRowSelect
                .ReadOnly = True

            End With


        Catch ex As Exception

        End Try
    End Sub

#End Region

#Region "Initialize"

    Private Sub Frm_INTElementmanagement_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loadDgvelement()
        loadDgvelementout()
        loadDgvelementC()
    End Sub



#End Region

#Region "sub and function"

    Private Function Bindhasttable(ByVal indx As Integer) As Hashtable
        Dim hast As New Hashtable

        With hast
            Select Case indx
                Case 0

                    .Add("BoNumA", "入庫單號碼")
                    .Add("GoodsBarcode", "貨品編號")
                    .Add("element", "元件號碼")
                    .Add("elementamount", "元件數量")
                    .Add("elementunit", "元件單位")
                    .Add("elementbatch", "元件批次")
                    .Add("storeplace", "庫位")
                    .Add("elementstatus", "元件狀態")
                    .Add("builtdate", "入庫日期")
                    .Add("builtcomputer", "操作電腦")
                Case 1
                    .Add("BoNumB", "出庫單號碼")
                    .Add("GoodsBarcode", "貨品編號")
                    .Add("element", "元件號碼")
                    .Add("elementamount", "元件數量")
                    .Add("elementunit", "元件單位")
                    .Add("elementbatch", "元件批次")
                    .Add("elementplace", "庫位")
                    .Add("elementstatus", "元件狀態")
                    .Add("builtdate", "出庫日期")
                    .Add("builtcomputer", "操作電腦")
                Case 2
                    .Add("goodsbarcode", "貨品編號")
                    .Add("element", "元件號碼")
                    .Add("elementamount", "元件數量")
                    .Add("elementunit", "元件單位")
                    .Add("elementbatch", "元件批次")
                    .Add("elementstatus", "元件狀態")
                    .Add("storeplace", "庫位")
                    .Add("Enname", "英文名")
                    .Add("Cnname", "貨品描述")
            End Select
            Return hast
        End With
    End Function

    Private Sub Findelement()
        Try
            Dim sql As String = "select BoNumA ,replace(GoodsBarcode,'*','') as GoodsBarcode,element,elementamount ,elementunit, elementbatch,storeplace,elementstatus from Stor_element where 1=1 "

            If Me.TxtBoNumA.Text.Length > 0 Then
                sql += " and BoNumA='" & Me.TxtBoNumA.Text & "'"
            End If
            If Me.Txtgoodsbarcode.Text.Length > 0 Then
                sql += " and Goodsbarcode='*'+'" & Me.Txtgoodsbarcode.Text & "'+'*'"
            End If
            If Me.Txtelement.Text.Length > 0 Then
                sql += " and element='" & Me.Txtelement.Text & "'"
            End If
            If Me.Txtelementbatch.Text.Length > 0 Then
                sql += " and elementbatch='" & Me.Txtelementbatch.Text & "'"
            End If
            If Me.Txtelementstatus.Text.Length > 0 Then
                sql += " and elementstatus='" & Me.Txtelementstatus.Text & "' "
            End If
            If Me.Txtstoreplace.Text.Length > 0 Then
                sql += " and storeplace='" + Me.Txtstoreplace.Text + "'"
            End If



            Returenelement = ReturnDataset(sql)

            If Returenelement.Tables(0).Rows.Count > 0 Then
                With MainForm
                    .ToolStripPrint.Enabled = True
                End With
            End If
            Me.Dgvelement.DataSource = Returenelement.Tables(0)
        Catch ex As Exception

        End Try

    End Sub

    Private Sub Findelementout()
        Try
            Dim sql As String = "select BoNumB ,replace(GoodsBarcode,'*','') as GoodsBarcode ,element,elementamount ,elementunit, elementbatch,elementplace,elementstatus from Stor_ElementOut where 1=1 "

            If Me.TxtBonumB.Text.Length > 0 Then
                sql += " and BoNumB='" & Me.TxtBonumB.Text & "'"
            End If
            If Me.TxtbarcodeB.Text.Length > 0 Then
                sql += " and Goodsbarcode='*'+'" & Me.TxtbarcodeB.Text & "'+'*'"
            End If
            If Me.TxtelemntB.Text.Length > 0 Then
                sql += " and element='" & Me.TxtelemntB.Text & "'"
            End If
            If Me.TxtelementbatchB.Text.Length > 0 Then
                sql += " and elementbatch='" & Me.TxtelementbatchB.Text & "'"
            End If
            If Me.TxtelementstatusB.Text.Length > 0 Then
                sql += " and elementstatus='" & Me.TxtelementstatusB.Text & "' "
            End If
            If Me.TxtstoreplaceB.Text.Length > 0 Then
                sql += " and elementamount='" + Me.TxtstoreplaceB.Text + "'"
            End If


            ''Dim Returenelement As New DataSet
            Returenelementout = ReturnDataset(sql)

            If Returenelementout.Tables(0).Rows.Count > 0 Then
                With MainForm
                    .ToolStripPrint.Enabled = True
                End With
            End If
            Me.Dgvelementout.DataSource = Returenelementout.Tables(0)

        Catch ex As Exception

        End Try

    End Sub

    Private Sub Findelementstatus()
        Try
            'Dim strsql As String = "select * from (select replace(a.goodsbarcode,'*','') as goodsbarcode,a.element,a.elementamount,a.elementunit,a.elementbatch,a.elementstatus,a.storeplace,a.bonuma,b.bonumb," & vbCrLf
            'strsql += "elmentisout= case isnull(b.bonumb,'1') when '1' then '未出庫' else  '已出庫'  End from Stor_element a left  join  stor_elementout b  on   a.element=b.element)  a  where 1=1"

            Dim strsql As String = "select replace(a.barcode,'*','') as goodsbarcode ," + vbNewLine
            strsql += "a.element,b.Enname,b.Cnname,a.qty as elementamount,a.unit as elementunit," + vbNewLine
            strsql += "a.elementbatch,a.status as elementstatus,a.place as storeplace " + vbNewLine
            strsql += "from dbo.Stor_Elmentstatus a" + vbNewLine
            strsql += "left join(select BarCode,Cnname,Enname from bsc_goods where goodsType not in(" + vbNewLine
            strsql += "select ID from dbo.BSC_GoodsType where isnull(NoFinished,'')='1')) b" + vbNewLine
            strsql += "on replace(a.barcode,'*','')=replace(b.BarCode,'*','')" + vbNewLine
            strsql += " where 1=1 "
            If Me.TxtbarcodeC.Text.Length > 0 Then
                strsql += " and replace(a.barcode,'*','')='" & Me.TxtbarcodeC.Text & "'"
            End If
            If Me.TxtelementC.Text.Length > 0 Then
                strsql += " and a.element='" & Me.TxtelementC.Text & "'"
            End If
            If Me.TxtelementbatchC.Text.Length > 0 Then
                strsql += " and a.elementbatch='" & TxtelementbatchC.Text & "'"
            End If
            If Me.TxtstoreplaceC.Text.Length > 0 Then
                strsql += " and a.place='" & TxtstoreplaceC.Text & "' "
            End If
            If Me.TxtelementstatusC.Text.Length > 0 Then
                strsql += " and a.status='" & TxtelementstatusC.Text & "'"
            End If

            If Me.txtEnnameC.TextLength > 0 Then
                strsql += " and b.Enname='" + Me.txtEnnameC.Text.Trim() + "'"
            End If



            Dim Ruturnelmentstatus As New DataSet
            Ruturnelmentstatus = ReturnDataset(strsql)

            If Ruturnelmentstatus.Tables(0).Rows.Count > 0 Then
                MainForm.ToolStripPrint.Enabled = True
            End If
            Me.DgvelementC.DataSource = Ruturnelmentstatus.Tables(0)

        Catch ex As Exception

        End Try
    End Sub

    Private Sub Cmdquery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmdquery.Click
        Findelement()
    End Sub

    Private Sub CmdoutelementB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdoutelementB.Click
        Findelementout()
    End Sub

    Private Sub Cmdelmentstatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmdelmentstatus.Click
        Findelementstatus()
    End Sub

    Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DelToolStripMenuItem1.Click
        Try
            If DeleteEnable = False Then
                MessageBox.Show(My.Resources.NotAllowDelete, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
            If MessageBox.Show("您確定要刪除此元件入庫記錄？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.Yes Then
                Dim BoNumA As String = ""
                Dim element As String = ""
                Dim strsql As String = ""
                BoNumA = Me.Dgvelement.CurrentRow.Cells("BoNumA").Value
                element = Me.Dgvelement.CurrentRow.Cells("element").Value
                strsql = "delete Stor_element where  BoNumA='" & BoNumA & "' and  element ='" & element & "'"
                Dim rst As New DataSet
                rst = ReturnDataset(strsql)

                Dim rows() As DataRow = Returenelement.Tables(0).Select(" BoNumA='" & BoNumA & "' and  element ='" & element & "'")
                If rows.Length > 0 Then
                    For Each row As DataRow In rows
                        Returenelement.Tables(0).Rows.Remove(row)
                    Next row
                    Returenelement.AcceptChanges()
                End If
            End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub DeleteToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem1.Click
        Try
            If DeleteEnable = False Then
                MessageBox.Show(My.Resources.NotAllowDelete, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
            If MessageBox.Show("您確定要刪除此元件出庫記錄？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.Yes Then
                Dim BoNumb As String = ""
                Dim element As String = ""
                Dim strsql As String = ""
                BoNumb = Me.Dgvelementout.CurrentRow.Cells("BoNumb").Value
                element = Me.Dgvelementout.CurrentRow.Cells("element").Value
                strsql = "delete Stor_ElementOut where  BoNumb='" & BoNumb & "' and  element ='" & element & "'"
                Dim rst As New DataSet
                rst = ReturnDataset(strsql)

                Dim rows() As DataRow = Returenelementout.Tables(0).Select(" BoNumb='" & BoNumb & "' and  element ='" & element & "'")
                If rows.Length > 0 Then
                    For Each row As DataRow In rows
                        Returenelementout.Tables(0).Rows.Remove(row)
                    Next row
                    Returenelementout.AcceptChanges()
                End If
            End If
        Catch ex As Exception
        End Try
    End Sub

#End Region


    Private Sub Dgvelement_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs)
    End Sub
    Private Sub Dgvelementout_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles Dgvelementout.RowPostPaint
        Dim SBrush As New SolidBrush(Dgvelementout.RowHeadersDefaultCellStyle.ForeColor)
        e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentCulture), e.InheritedRowStyle.Font, SBrush, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4)
    End Sub

    Private Sub Dgvelement_RowPostPaint1(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles Dgvelement.RowPostPaint
        Dim SBrush As New SolidBrush(Dgvelement.RowHeadersDefaultCellStyle.ForeColor)
        e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentCulture), e.InheritedRowStyle.Font, SBrush, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4)
    End Sub

    Private Sub DgvelementC_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DgvelementC.RowPostPaint
        Dim sbrush As New SolidBrush(Me.DgvelementC.RowHeadersDefaultCellStyle.ForeColor)
        e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentCulture), e.InheritedRowStyle.Font, sbrush, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4)
    End Sub

    Public Function ActionAdd() As Boolean Implements IDServer.IDServer.IDServer.ActionAdd

    End Function

    Public Function ActionCancel() As Boolean Implements IDServer.IDServer.IDServer.ActionCancel

    End Function

    Public Function ActionDelete() As Boolean Implements IDServer.IDServer.IDServer.ActionDelete

    End Function

    Public Function ActionEdit() As Boolean Implements IDServer.IDServer.IDServer.ActionEdit

    End Function

    Public Function ActionExport() As Boolean Implements IDServer.IDServer.IDServer.ActionExport

    End Function

    Public Function ActionFilter() As Boolean Implements IDServer.IDServer.IDServer.ActionFilter

    End Function

    Public Function ActionGoFirst() As Boolean Implements IDServer.IDServer.IDServer.ActionGoFirst

    End Function

    Public Function ActionGoLast() As Boolean Implements IDServer.IDServer.IDServer.ActionGoLast

    End Function

    Public Function ActionGoNext() As Boolean Implements IDServer.IDServer.IDServer.ActionGoNext

    End Function

    Public Function ActionGoPrevious() As Boolean Implements IDServer.IDServer.IDServer.ActionGoPrevious

    End Function

    Public Function ActionImport() As Boolean Implements IDServer.IDServer.IDServer.ActionImport

    End Function

    Public Function ActionInitialize() As Boolean Implements IDServer.IDServer.IDServer.ActionInitialize

    End Function

    Public Function ActionPrint() As Boolean Implements IDServer.IDServer.IDServer.ActionPrint
        Try
            Dim Sql As String = String.Empty
            Dim mServer As String = String.Empty
            Dim mDatabase As String = String.Empty
            Dim mUid As String = String.Empty
            Dim mPwd As String = String.Empty
            Dim PathStr As String = String.Empty

            Dim Element As String = String.Empty
            Dim OriginalTable As DataTable = Nothing
            Dim ElementStr As System.Text.StringBuilder = New System.Text.StringBuilder

            Dim ConfigureNode() As String = ReadConfigFile.Split(";")

            PathStr = GetReportPath("Store", "RepElement.rpt")

            If ConfigureNode.Length > 0 Then
                For i As Integer = 0 To ConfigureNode.Length - 1
                    If ConfigureNode(i).Split("=")(0).ToLower = "Server".ToLower Then
                        mServer = ConfigureNode(i).Split("=")(1)
                    End If
                    If ConfigureNode(i).Split("=")(0).ToLower = "Database".ToLower Then
                        mDatabase = ConfigureNode(i).Split("=")(1)
                    End If
                    If ConfigureNode(i).Split("=")(0).ToLower = "Uid".ToLower Then
                        mUid = ConfigureNode(i).Split("=")(1)
                    End If
                    If ConfigureNode(i).Split("=")(0).ToLower = "Pwd".ToLower Then
                        mPwd = ConfigureNode(i).Split("=")(1)
                    End If
                Next
            End If

            Dim MyReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim LogOnInfo As New CrystalDecisions.Shared.TableLogOnInfo
            Dim Table As CrystalDecisions.CrystalReports.Engine.Table

            MyReportDocument.Load(PathStr)
            For Each Table In MyReportDocument.Database.Tables
                LogOnInfo = Table.LogOnInfo
                With LogOnInfo.ConnectionInfo
                    .ServerName = mServer
                    .DatabaseName = mDatabase
                    .UserID = mUid
                    .Password = mPwd
                End With
                Table.ApplyLogOnInfo(LogOnInfo)
            Next

            Select Case Me.TabControl1.SelectedIndex
                Case 0
                    If Me.Dgvelement.RowCount > 0 Then
                        OriginalTable = DirectCast(Me.Dgvelement.DataSource, DataTable)
                    End If
                Case 1
                    If Me.Dgvelementout.RowCount > 0 Then

                        OriginalTable = DirectCast(Me.Dgvelementout.DataSource, DataTable)
                    End If
                Case 2
                    If Me.DgvelementC.RowCount > 0 Then

                        OriginalTable = DirectCast(Me.DgvelementC.DataSource, DataTable)
                    End If
            End Select
            Select Case Me.TabControl1.SelectedIndex
                Case 0
                    If Me.Dgvelement.SelectedRows.Count > 0 Then
                        For i As Integer = 0 To Me.Dgvelement.SelectedRows.Count - 1
                            Element = Me.Dgvelement.SelectedRows(i).Cells("element").Value & ""
                            If ElementStr.Length > 0 Then
                                ElementStr.Append(",")
                            End If
                            ElementStr.Append("'")
                            ElementStr.Append(Element)
                            ElementStr.Append("'")
                        Next
                    End If
                Case 1
                    If Me.Dgvelementout.SelectedRows.Count > 0 Then
                        If Me.Dgvelementout.SelectedRows.Count > 0 Then
                            For i As Integer = 0 To Me.Dgvelementout.SelectedRows.Count - 1
                                Element = Me.Dgvelementout.SelectedRows(i).Cells("element").Value & ""
                                If ElementStr.Length > 0 Then
                                    ElementStr.Append(",")
                                End If
                                ElementStr.Append("'")
                                ElementStr.Append(Element)
                                ElementStr.Append("'")
                            Next
                        End If
                    End If
                Case 2
                    If Me.DgvelementC.SelectedRows.Count > 0 Then
                        If Me.DgvelementC.SelectedRows.Count > 0 Then
                            For i As Integer = 0 To Me.DgvelementC.SelectedRows.Count - 1
                                Element = Me.DgvelementC.SelectedRows(i).Cells("element").Value & ""
                                If ElementStr.Length > 0 Then
                                    ElementStr.Append(",")
                                End If
                                ElementStr.Append("'")
                                ElementStr.Append(Element)
                                ElementStr.Append("'")
                            Next
                        End If
                    End If
            End Select
            Dim Newstr As String = ElementStr.ToString
            If Newstr.Length = 0 Then
                MessageBox.Show("沒有元件可以列印，請選擇元件號", Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2)
                Exit Function
            End If
            'Sql = "select '*'+a.Element+'*' as Element,'S/N:'+a.Element as ElementNo,b.supperitem as supperitem,b.enname as enname  from dbo.Stor_element a ,bsc_goods b where a.goodsbarcode=b.barcode and a.element in (" & Newstr & ")"

            Sql = "select '*'+a.Element+'*' as Element,'S/N:'+a.Element as ElementNo,b.supperitem"
            Sql += " as supperitem,b.enname as enname from dbo.Stor_Elmentstatus a "
            Sql += " left join bsc_goods b "
            Sql += " on a.barcode=b.barcode "
            Sql += " where a.element in (" + Newstr + ")"
            Dim dt As DataTable = Exec(Sql, E_ExecType.DataTable)
            If dt.Rows.Count = 0 Then
                Sql = "select '*'+a.Element+'*' as Element,'S/N:'+a.Element as ElementNo,b.supperitem as supperitem,b.enname as enname from dbo.Stor_element a left join bsc_goods b on a.goodsbarcode=b.barcode where a.element in (" + Newstr + ")"
                dt = Exec(Sql, E_ExecType.DataTable)
                If dt.Rows.Count = 0 Then
                    Sql = "select '*'+a.Element+'*' as Element,'S/N:'+a.Element as ElementNo,b.supperitem as supperitem,b.enname as enname from dbo.Stor_ElementOut a left join bsc_goods b on a.goodsbarcode=b.barcode where a.element in (" + Newstr + ")"
                    dt = Exec(Sql, E_ExecType.DataTable)
                End If
            End If

            If dt.Rows.Count = 0 Then
                Msg.MsgOK("找不到需要列印的元件信息")
                Exit Function
            End If
            MyReportDocument.SetDataSource(dt)
            My.Forms.Frm_Report.CrystalReportViewer1.ReportSource = MyReportDocument
            My.Forms.Frm_Report.CrystalReportViewer1.Zoom(1)
            My.Forms.Frm_Report.CrystalReportViewer1.DisplayGroupTree = False
            Frm_Report.ShowDialog()

        Catch ex As Exception
            MessageBox.Show("Error: " + ex.ToString, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Function

    Public Function ActionSave() As Boolean Implements IDServer.IDServer.IDServer.ActionSave

    End Function

    Public Function ActionSelect() As Boolean Implements IDServer.IDServer.IDServer.ActionSelect

    End Function

    Private Sub TxtelementC_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtelementC.TextChanged

    End Sub

    Private Sub SplitContainer1_Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Panel2.Paint

    End Sub

    Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter

    End Sub
End Class
